package com.lanswon.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lanswon.common.enums.ArticleStatus;
import com.lanswon.entity.ArticleVO;
import com.lanswon.entity.HostBank;
import com.lanswon.service.ArticleService;
import com.lanswon.service.HostbankService;

/**
 *主办行
 */
@Controller
@RequestMapping("/front/hostbank")
public class HostBankController {
	
	@Autowired
	private HostbankService hostbankService;
	
	@RequestMapping("index/{hostbankType}")
	public String index(HttpServletRequest request,HttpServletResponse response,ModelMap modelMap,
			@PathVariable(value="hostbankType")Integer hostbankType) {
		
		modelMap.addAttribute("hostbankType", hostbankType);
		return "/front/hostbank/index";
	}
	
	@RequestMapping("detail/{hostbankType}")
	@ResponseBody
	public Map<String, Object> detail(HttpServletRequest request,HttpServletResponse response,@PathVariable("hostbankType") Integer hostbankType){
		Map<String, Object> viewMap = new HashMap<>();
		try {
			Map<String, Object> accessMap = new HashMap<>();
			accessMap.put("hostbankType", hostbankType);
			List<HostBank> hbList = hostbankService.findHostbankByCondition(accessMap);
			viewMap.put("code", 0);
			viewMap.put("message", "查询成功");
			viewMap.put("hostbankType", hostbankType);
			viewMap.put("data", hbList!=null&&hbList.size()>0?hbList.get(0):null);
		} catch (Exception e) {
			e.printStackTrace();
			viewMap.put("code", 2);
			viewMap.put("message", "查询失败");
		}
		return viewMap;
	}
	
}
